Skip to content

Set sampler feedback shader flag when sampler feedback operations are used (and validator version >= 1.9)#8567

Merged
Icohedron merged 1 commit into
microsoft:mainfrom
Icohedron:sampler-feedback-flag
Jun 22, 2026
Merged

Set sampler feedback shader flag when sampler feedback operations are used (and validator version >= 1.9)#8567
Icohedron merged 1 commit into
microsoft:mainfrom
Icohedron:sampler-feedback-flag

Conversation

@Icohedron

Copy link
Copy Markdown
Collaborator

Fixes #8533

This PR sets the sampler feedback DXIL feature flag in the presence of sampler feedback operations when the validator version is >= 1.9.
A lit test has also added to verify the functionality.

Assisted-by: Claude Opus 4.8

Detect sampler feedback DXIL ops when collecting shader flags and
gate the SamplerFeedback requirement by validator version >= 1.9.
Add an HLSL FileCheck test covering both enabled and gated behavior.

Assisted-by: Claude Opus 4.8
@Icohedron

Copy link
Copy Markdown
Collaborator Author

I could also add a validator test but I don't think it is necessary. The validator already has two smoke tests ensuring that the validator validates the setting of shader flags. Explicit support for new shader flags does not need to be added to the validator since they are picked up automatically from DxilShaderFlags.cpp.

diff --git a/tools/clang/unittests/HLSL/ValidationTest.cpp b/tools/clang/unittests/HLSL/ValidationTest.cpp
index 67c22e7b..f1fb6208 100644
--- a/tools/clang/unittests/HLSL/ValidationTest.cpp
+++ b/tools/clang/unittests/HLSL/ValidationTest.cpp
@@ -217,6 +217,7 @@ public:
 
   TEST_METHOD(WhenMetaFlagsUsageDeclThenOK)
   TEST_METHOD(WhenMetaFlagsUsageThenFail)
+  TEST_METHOD(WhenMetaFlagsSamplerFeedbackThenFail)
 
   TEST_METHOD(WhenRootSigMismatchThenFail)
   TEST_METHOD(WhenRootSigCompatThenSucceed)
@@ -1843,6 +1844,17 @@ TEST_F(ValidationTest, WhenMetaFlagsUsageThenFail) {
                           "Flags must match usage");
 }
 
+TEST_F(ValidationTest, WhenMetaFlagsSamplerFeedbackThenFail) {
+  if (m_ver.SkipDxilVersion(1, 9))
+    return;
+  RewriteAssemblyCheckMsg(
+      "FeedbackTexture2D<SAMPLER_FEEDBACK_MIN_MIP> fb; Texture2D<float> t; "
+      "SamplerState s; float main() : SV_Target { "
+      "fb.WriteSamplerFeedback(t, s, (float2)0); return 0; }",
+      "ps_6_5", "67108864", "0", // remove the sampler feedback flag
+      "Flags must match usage");
+}
+
 TEST_F(ValidationTest, StorePatchControlNotInPatchConstantFunction) {
   if (m_ver.SkipDxilVersion(1, 3))
     return;

@hekota hekota left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Icohedron Icohedron merged commit 0911074 into microsoft:main Jun 22, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

SM 6.5+ Sampler feedback DXIL shader flag is not set

3 participants